package prettyprolog.datatypes;


import java.util.*;
import prettyprolog.engine.NotDefinedDomain;



public class Constraint implements Term {


    protected List<Term> cons;
    protected int consn;


    /** Constructs a new Cons with the given car and cdr. */
    public Constraint() throws NotDefinedDomain {
        this(new Vector<Term>());
    }
    
    public void cleanConstraint() {
    	cons.clear();
    }

    public Constraint(List<Term> v) throws NotDefinedDomain {
        cons  = new Vector<Term>(v);
        consn = cons.size();
    }

    public List<Term> getCons() {
        return cons;
    }

    public Term getEl(int i) {
        return cons.get(i);
    }

    public int getConsCount() {
        return consn;
    }

    public boolean isEmpty() {
        return cons.isEmpty();
    }

    public void removeAll() {
        for(int i=0; i < cons.size(); i++) {
            cons.remove(i);
            i--;
        }
    }

    public Constraint addEl(Term t) throws NotDefinedDomain {
        cons.add(t);
        return this;
    }


    public String toString() {
	String s = "";
	if(consn > 0) {
//	    s += "{";
	    int i;
	    for(i = 0; i < consn - 1; i++)
		s += cons.get(i) + ", ";
	    s += cons.get(i);
//	    s += "}";
	}
	return s+".";
    }



    public Term apply(Substitution subst) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isGround() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isGround(boolean strict) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Term copy(Substitution vars) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean contains(Term t) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean contains(Term t, boolean deep) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
